/* GUI CONVERTED from rsrp02a.p (converter v1.75) Tue Nov  7 07:30:11 2000 */
/* rsrp02a.p - Release Management Supplier Schedules                    */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/*F0PN*/ /*V8:ConvertMode=Report                                        */
/* REVISION: 7.0    LAST MODIFIED: 01/29/92           BY: WUG *F110*    */
/* REVISION: 7.0    LAST MODIFIED: 03/16/92           BY: WUG *F312*    */
/* REVISION: 7.0    LAST MODIFIED: 03/26/92           BY: WUG *F323*    */
/* REVISION: 7.3    LAST MODIFIED: 10/13/92           BY: WUG *G462*    */
/* REVISION: 7.3    LAST MODIFIED: 07/14/93           BY: WUG *GD42*    */
/* REVISION: 8.5    LAST MODIFIED: 03/21/95           BY: dpm *J044*    */
/* REVISION: 7.4    LAST MODIFIED: 10/22/95           BY: vrn *G0YF*    */
/* REVISION: 8.5    LAST MODIFIED: 02/21/96           BY: kjm *G1NR*    */
/* REVISION: 8.6E   LAST MODIFIED: 02/23/98 BY: *L007* A. Rahane        */
/* REVISION: 8.6E   LAST MODIFIED: 05/20/98 BY: *K1Q4* Alfred Tan       */
/* REVISION: 8.6E   LAST MODIFIED: 08/17/98 BY: *L062* Steve Nugent     */
/* REVISION: 8.6E   LAST MODIFIED: 10/04/98 BY: *J314* Alfred Tan       */
/* REVISION: 9.1    LAST MODIFIED: 03/24/00 BY: *N08T* Annasaheb Rahane */
/* REVISION: 9.1    LAST MODIFIED: 08/12/00 BY: *N0KP* myb              */
/* REVISION: 9.1    LAST MODIFIED: 09/11/00 BY: *N0RT* Mudit Mehta      */
     /* SCHEDULE COMPARE SUBPROGRAM */


/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

         {mfdeclre.i}
         {gplabel.i} /* EXTERNAL LABEL INCLUDE */

/* ********** Begin Translatable Strings Definitions ********* */

&SCOPED-DEFINE rsrp02a_p_2 "Qty Diff"
/* MaxLen: Comment: */

&SCOPED-DEFINE rsrp02a_p_3 "Int"
/* MaxLen: Comment: */

&SCOPED-DEFINE rsrp02a_p_4 "Cumulative!Qty"
/* MaxLen: Comment: */

&SCOPED-DEFINE rsrp02a_p_5 "Cum Qty Diff"
/* MaxLen: Comment: */

&SCOPED-DEFINE rsrp02a_p_6 "Discrete!Qty"
/* MaxLen: Comment: */

/*N0RT***********BEGIN COMMENTING*************
 * &SCOPED-DEFINE rsrp02a_p_1 "Release ID"
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rsrp02a_p_7 "Prior"
 * /* MaxLen: Comment: */
 *N0RT***********END COMMENTING************* */

&SCOPED-DEFINE rsrp02a_p_8 "Subcontract Type"
/* MaxLen: Comment: */

/* ********** End Translatable Strings Definitions ********* */

         define shared buffer schmstr1 for sch_mstr.
         define shared buffer schmstr2 for sch_mstr.
         define buffer schddet1 for schd_det.
         define buffer schddet2 for schd_det.

         define variable diff_qty like ld_qty_oh label {&rsrp02a_p_2}.
         define variable cum_diff_qty like ld_qty_oh label {&rsrp02a_p_5}.
         define variable disp_date like schd_date.
         define variable disp_time like schd_time format "XX:XX".
         define variable disp_interval like schd_interval
                                       column-label {&rsrp02a_p_3}.
         define variable disp_reference like schd_reference format "x(24)".
         define variable first_pass like mfc_logical initial yes.
         define variable key1 as character.
         define variable key2 as character.
         define variable cum1_qty like schd_cum_qty.
         define variable cum2_qty like schd_cum_qty.
/*J044*/ define variable impexp like mfc_logical.
/*L062*/ define variable subtype as character format "x(12)"
                                 label {&rsrp02a_p_8} no-undo.

         {rsordfrm.i}

         find pod_det where pod_nbr = schmstr1.sch_nbr
         and pod_line = schmstr1.sch_line no-lock.

         find scx_ref where scx_type = 2 and scx_order = pod_nbr
         and scx_line = pod_line no-lock.
         find po_mstr where po_nbr = scx_order exclusive-lock.
         find si_mstr where si_site = scx_shipto no-lock.
         find ad_mstr where ad_addr = scx_shipfrom no-lock.
         find pt_mstr where pt_part = scx_part no-lock.

         display
            scx_shipfrom
            scx_shipto
            ad_name
            scx_part
            pod_vpart
/*GD42*/    pod_um
            scx_po
            skip(1)
            scx_line
            skip(1)
/*G0YF*  with frame a.  */
/*G0YF*/ with frame prm STREAM-IO /*GUI*/ .

         find first schddet1
         where schddet1.schd_type = schmstr1.sch_type
         and schddet1.schd_nbr = schmstr1.sch_nbr
         and schddet1.schd_line = schmstr1.sch_line
         and schddet1.schd_rlse_id = schmstr1.sch_rlse_id
         no-lock no-error.

         find first schddet2
         where schddet2.schd_type = schmstr2.sch_type
         and schddet2.schd_nbr = schmstr2.sch_nbr
         and schddet2.schd_line = schmstr2.sch_line
         and schddet2.schd_rlse_id = schmstr2.sch_rlse_id
         no-lock no-error.

/*N0RT*  repeat while available schddet1 or available schddet2: */
/*N0RT*/ repeat while available schddet1 or available schddet2 with frame f-a:

            
/*GUI*/ {mfguichk.i } /*Replace mfrpchk*/


            FORM /*GUI*/ 
               disp_date
               disp_time
               disp_interval
               disp_reference
/*G1NR*        space(3) */
               schddet1.schd_discr_qty   column-label {&rsrp02a_p_6}
               schddet1.schd_cum_qty     column-label {&rsrp02a_p_4}
               schddet1.schd_fc_qual
/*G1NR*        space(3) */
               schddet2.schd_discr_qty   column-label {&rsrp02a_p_6}
               schddet2.schd_cum_qty     column-label {&rsrp02a_p_4}
               schddet2.schd_fc_qual
/*G1NR*        space(3) */
               diff_qty
               cum_diff_qty
/*N0RT*/    with STREAM-IO /*GUI*/  frame f-a width 132 no-box.

            /* SET EXTERNAL LABELS */
/*N0RT*/    setFrameLabels(frame f-a:handle).

/*N0RT*
 *          header
 *             {&rsrp02a_p_1}                      at 47
 *             {&rsrp02a_p_1}                      at 77
 *N0RT*/
/*N0RT*/    FORM /*GUI*/  header
/*N0RT*/       getTermLabel("RELEASE_ID",20)    at 47 format "x(20)"
/*N0RT*/       getTermLabel("RELEASE_ID",20)    at 77 format "x(20)"
               fill("-",27) format "x(27)"       at 47
               fill("-",27) format "x(27)"       at 77
               schddet1.schd_rlse_id             at 47
               schddet2.schd_rlse_id             at 77
               " "                               at 47
/*N0RT*     with width 132 no-box. */
/*N0RT*/    with STREAM-IO /*GUI*/  frame f-hdr-a width 132 no-box.

/*N0RT*/    view frame f-hdr-a.

            if first_pass then do:
               display
/*N0RT*           {&rsrp02a_p_7} @ disp_date */
/*N0RT*/          getTermLabel("PRIOR",8) @ disp_date
                  schmstr1.sch_pcr_qty @ schddet1.schd_cum_qty
                  schmstr2.sch_pcr_qty @ schddet2.schd_cum_qty WITH STREAM-IO /*GUI*/ .

               down 1.

               first_pass = no.
            end.

            if available schddet1 then do:
                key1 = string(year(schddet1.schd_date),"9999")
                       + string(month(schddet1.schd_date),"99")
                       + string(day(schddet1.schd_date),"99")
                       + string(schddet1.schd_time,"x(4)")
                       + string(schddet1.schd_interval,"x(1)")
                       + schddet1.schd_reference.
            end.

            if available schddet2 then do:
               key2 = string(year(schddet2.schd_date),"9999")
                      + string(month(schddet2.schd_date),"99")
                      + string(day(schddet2.schd_date),"99")
                      + string(schddet2.schd_time,"x(4)")
                      + string(schddet2.schd_interval,"x(1)")
                     + schddet2.schd_reference.
            end.

            if available schddet1 and
            (not available schddet2
             or key1 < key2)
            then do:

               cum1_qty = schddet1.schd_cum_qty.
               diff_qty =  - schddet1.schd_discr_qty.
               cum_diff_qty = cum2_qty - cum1_qty.

               display
                  schddet1.schd_date @ disp_date
                  schddet1.schd_time format "XX:XX"
/*G1NR*              when schddet1.schd_time <> "" @ disp_time */
/*G1NR*/             when (schddet1.schd_time <> "") @ disp_time
                  schddet1.schd_interval @ disp_interval
                  schddet1.schd_reference @ disp_reference
                  schddet1.schd_discr_qty
                  schddet1.schd_cum_qty
                  schddet1.schd_fc_qual
/*G1NR*           diff_qty when diff_qty <> 0 */
/*G1NR*           cum_diff_qty when cum_diff_qty <> 0. */
/*G1NR*/          diff_qty when (diff_qty <> 0)
/*G1NR*/          cum_diff_qty when (cum_diff_qty <> 0) WITH STREAM-IO /*GUI*/ .

               find next schddet1
               where schddet1.schd_type = schmstr1.sch_type
               and schddet1.schd_nbr = schmstr1.sch_nbr
               and schddet1.schd_line = schmstr1.sch_line
               and schddet1.schd_rlse_id = schmstr1.sch_rlse_id
               no-lock no-error.

            end.

            else
           if available schddet2 and
           (not available schddet1
            or key2 < key1)
           then do:

               cum2_qty = schddet2.schd_cum_qty.
               diff_qty = schddet2.schd_discr_qty.
               cum_diff_qty = cum2_qty - cum1_qty.

               display
                  schddet2.schd_date @ disp_date
                  schddet2.schd_time format "XX:XX"
/*G1NR*              when schddet2.schd_time <> "" @ disp_time */
/*G1NR*/             when (schddet2.schd_time <> "") @ disp_time
                  schddet2.schd_interval @ disp_interval
                  schddet2.schd_reference @ disp_reference
                  schddet2.schd_discr_qty
                  schddet2.schd_cum_qty
                  schddet2.schd_fc_qual
/*G1NR*           diff_qty when diff_qty <> 0 */
/*G1NR*           cum_diff_qty when cum_diff_qty <> 0. */
/*G1NR*/          diff_qty when (diff_qty <> 0)
/*G1NR*/          cum_diff_qty when (cum_diff_qty <> 0) WITH STREAM-IO /*GUI*/ .

               find next schddet2
               where schddet2.schd_type = schmstr2.sch_type
               and schddet2.schd_nbr = schmstr2.sch_nbr
               and schddet2.schd_line = schmstr2.sch_line
               and schddet2.schd_rlse_id = schmstr2.sch_rlse_id
               no-lock no-error.

            end.

            else do:

               cum1_qty = schddet1.schd_cum_qty.
               cum2_qty = schddet2.schd_cum_qty.
               diff_qty = schddet2.schd_discr_qty - schddet1.schd_discr_qty.
               cum_diff_qty = cum2_qty - cum1_qty.

               display
                 schddet1.schd_date @ disp_date
                 schddet1.schd_time format "XX:XX"
/*G1NR*             when schddet1.schd_time <> "" @ disp_time */
/*G1NR*/            when (schddet1.schd_time <> "") @ disp_time
                 schddet1.schd_interval @ disp_interval
                 schddet1.schd_reference @ disp_reference
                 schddet1.schd_discr_qty
                 schddet1.schd_cum_qty
                 schddet1.schd_fc_qual
                 schddet2.schd_discr_qty
                 schddet2.schd_cum_qty
                 schddet2.schd_fc_qual
/*G1NR*          diff_qty when diff_qty <> 0 */
/*G1NR*          cum_diff_qty when cum_diff_qty <> 0. */
/*G1NR*/         diff_qty when (diff_qty <> 0)
/*G1NR*/         cum_diff_qty when (cum_diff_qty <> 0) WITH STREAM-IO /*GUI*/ .

               find next schddet1
               where schddet1.schd_type = schmstr1.sch_type
               and schddet1.schd_nbr = schmstr1.sch_nbr
               and schddet1.schd_line = schmstr1.sch_line
               and schddet1.schd_rlse_id = schmstr1.sch_rlse_id
               no-lock no-error.

               find next schddet2
               where schddet2.schd_type = schmstr2.sch_type
               and schddet2.schd_nbr = schmstr2.sch_nbr
               and schddet2.schd_line = schmstr2.sch_line
               and schddet2.schd_rlse_id = schmstr2.sch_rlse_id
               no-lock no-error.

            end.

         end.
